package lib.bone.ext.draft;

import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;

import java.util.List;
import java.util.Optional;

public interface NepuDraftDAO extends JpaRepository<NepuDraft,String> {
    /**
     * 获取最新一次提交
     * @param userId
     * @param formId
     * @return
     */
    Optional<NepuDraft> findTopByUserIdAndFormIdOrderByCreatedTimeDesc(Long userId,String formId);


    /**
     * 获取用户某表单全部暂存
     * @param userId
     * @param formId
     * @return
     */
    List<NepuDraft> findAllByUserIdAndFormIdOrderByCreatedTimeDesc(Long userId,String formId);


    @Modifying
    void deleteByFormId(String formId);

}
